import 'dart:convert';


import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import '../constant.dart';


class AMapPolygonController {
  
  final MethodChannel mapPolygonChannel;

  AMapPolygonController.withId(int id) : mapPolygonChannel = MethodChannel('$AMAP_CHANNEL_NAME/amap_polygon$id');

  ///设置围栏
  ///参数:根据数据定制型方法,参数请参考dart/Android/iOS代码
  Future<bool> drawPolygon(Map<String, dynamic> map) async {
    debugPrint('方法:drawPolygon dart端参数:-> $map');
    return await mapPolygonChannel.invokeMethod("drawPolygon", map);
  }

  ///地图定位到给定的点
  ///LatLng nowLatLng = new LatLng(latitude: num, longitude: num);
  ///参数:Map<String, dynamic> map = {"location": json.encode(nowLatLng)};
  Future<bool> goLocation(Map<String, dynamic> map) async {
    debugPrint('方法:goLocation dart端参数:-> $map');
    return await mapPolygonChannel.invokeMethod("goLocation", map);
  }

  ///将屏幕中心定位到围栏内
  ///  ///参数:根据数据定制型方法,参数请参考dart/Android/iOS代码
  Future<bool> polygonInside(Map<String, dynamic> map) async {
    debugPrint('方法:polygonInside dart端参数:-> $map');
    return await mapPolygonChannel.invokeMethod("polygonInside", map);
  }

  ///设置地图的手势开关
  ///参数: Map<String, dynamic> locationMap = {"isEnabled": bool};
  Future<bool> setAllGestures(Map<String, dynamic> map) async {
    debugPrint('方法:setAllGestures dart端参数:-> $map');
    return await mapPolygonChannel.invokeMethod("setAllGestures", map);
  }

  ///设置地图的缩放比例 地图的缩放级别一共分为 17 级，从 3 到 19。数字越大，展示的图面信息越精细。
  ///参数: Map<String, dynamic> locationMap = {"num": int};
  Future<bool> setZoomTo(Map<String, dynamic> map) async {
    debugPrint('方法:setZoomTo dart端参数:-> $map');
    return await mapPolygonChannel.invokeMethod("setZoomTo", map);
  }

  ///~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


  ///判断点是否在围栏内 未使用到
  Future<bool> polygonCon(Map<String, dynamic> map) async {
    debugPrint('方法:polygonCon dart端参数:-> $map');
    return await mapPolygonChannel.invokeMethod("polygonCon", map);
  }
  
}